﻿
using System.Resources;
using System.Reflection;
using System;
namespace ToolGab
{
    public class Translation
    {
        ///----------------------------------------------------------------------------------------
        /// <summary>
        /// Translate the text into the good languages, if no translation available, it will be
        /// the string provided.
        /// </summary>
        /// <param name="Text">The string to translate</param>
        /// <returns>The translation</returns>
        ///----------------------------------------------------------------------------------------
        public static string Translate(string Text)
        {
            try
            {
                ResourceManager LocRM = new ResourceManager("ToolGab.ToolGabResources", Assembly.GetExecutingAssembly());
                LocRM.IgnoreCase = true;


                string newText = LocRM.GetString(Text);

                if (newText == string.Empty || newText == null)
                    return Text;
                else
                    return newText;
            }
            catch (Exception)
            {
                // We did not succeed in our translation, we return the same text.
                return Text;
            }

        }
    }
}
